package com.wlf.entity;

import java.io.Serializable;

/**
 * @author lingfeng.wei
 * @date 2021/7/5 17:29
 */

public class ApiResponse<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 接口调用返回是否成功
     */
    private boolean success;

    /**
     * 接口调用返回消息
     */
    private String message;

    /**
     * 接口调用返回代码
     */
    private String code;

    /**
     * 接口调用返回内容
     */
    private T body;

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }

    public static <T> ApiResponse<T> success(String code, String msg, T body) {
        ApiResponse<T> resp = new ApiResponse<T>();
        resp.setCode(code);
        resp.setMessage(msg);
        resp.setSuccess(true);
        resp.setBody(body);
        return resp;
    }
}
